package com.youku.controls
{
   import com.youku.plugins.topbarV4.TopbarFacade;
   import com.youku.GlobalService;
   import com.youku.GlobalServiceKeys;
   import com.youku.events.PluginEvent;
   import com.youku.events.PlayerControlEvent;
   import com.youku.PlayerConfig;
   
   public class TopbarV4Controller extends BasePluginController
   {
      
      public function TopbarV4Controller() {
         super();
         this.init();
      }
      
      private var _topbarFacade:TopbarFacade;
      
      override protected function init() : void {
         this._topbarFacade = TopbarFacade.getInstance();
         this._topbarFacade.init(viewManager.controlsLayer,playerProxy);
         GlobalService.addService(GlobalServiceKeys.TOPBAR_FACADE,this._topbarFacade);
         playerProxy.addEventListener(PluginEvent.TOPBAR_CLOSE_FULLSCREEN,this.onTopbarEvent);
         playerProxy.addEventListener(PluginEvent.TOPBAR_CHANGE_SCREEN_TYPE,this.onTopbarEvent);
      }
      
      private function onTopbarEvent(param1:PluginEvent) : void {
         var _loc2_:String = null;
         switch(param1.type)
         {
            case PluginEvent.TOPBAR_CHANGE_SCREEN_TYPE:
               _loc2_ = param1.data as String;
               playerProxy.dispatchEvent(new PlayerControlEvent(PlayerControlEvent.CORE_CHANGE_SCREEN_MODE,
                  {
                     "mode":_loc2_,
                     "tween":true
                  }));
               playerProxy.fsoProxy.saveScreenMode(_loc2_);
               break;
            case PluginEvent.TOPBAR_CLOSE_FULLSCREEN:
               if(PlayerConfig.isFullScreen)
               {
                  changeFullScreenMode();
               }
               break;
         }
      }
   }
}
